package com.fivestar.pmanager.service;

import java.util.List;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fivestar.pmanager.core.base.BaseCommonParameterBean;
import com.fivestar.pmanager.core.exception.DMLNoRecordEffectedException;
import com.fivestar.pmanager.core.service.BaseServiceImpl;
import com.fivestar.pmanager.dao.mapper.SysLoginLogMapper;
import com.fivestar.pmanager.model.SysLoginLogBean;

 /**
 * 运营平台用户登录日志
 * SysLoginLogService
 * @author 
 */
@Service("sysLoginLogService")
public class SysLoginLogService extends BaseServiceImpl<SysLoginLogBean>
{
	private final static Logger log = Logger.getLogger(SysLoginLogService.class);
	@Autowired
    private SysLoginLogMapper mapper;


    @Override
    public int insert(SysLoginLogBean sysLoginLogBean, BaseCommonParameterBean commonParam)
            throws DMLNoRecordEffectedException
    {
    	sysLoginLogBean.initBeforeCreate(commonParam.getActorId());
        int result;
        if ((result = mapper.insert(sysLoginLogBean)) != 1)
        {
            throw new DMLNoRecordEffectedException();
        }
        return result;
    }


    @Override
    public int delete(SysLoginLogBean smSystemLoginLog, BaseCommonParameterBean commonParam)
            throws DMLNoRecordEffectedException
    {
        smSystemLoginLog.initBeforeUpdate(commonParam.getActorId());
        int result;
        if ((result = mapper.delete(smSystemLoginLog)) != 1)
        {
            throw new DMLNoRecordEffectedException();
        }
        return result;
    }

    @Override
    public int deletePhysics(SysLoginLogBean smSystemLoginLog, BaseCommonParameterBean commonParam)
            throws DMLNoRecordEffectedException {
        int result;
        if ((result = mapper.deletePhysics(smSystemLoginLog)) != 1)
        {
            throw new DMLNoRecordEffectedException();
        }
        return result;
    }


    @Override
    public int update(SysLoginLogBean smSystemLoginLog, BaseCommonParameterBean commonParam)
            throws DMLNoRecordEffectedException
    {
        smSystemLoginLog.initBeforeUpdate(commonParam.getActorId());
        int result;
        if ((result = mapper.update(smSystemLoginLog)) != 1)
        {
            throw new DMLNoRecordEffectedException();
        }
        return result;
    }
    
    
    @Override
    public int updateBySelective(SysLoginLogBean smSystemLoginLog, BaseCommonParameterBean commonParam)
            throws DMLNoRecordEffectedException
    {
        smSystemLoginLog.initBeforeUpdate(commonParam.getActorId());
        int result;
        if ((result = mapper.updateBySelective(smSystemLoginLog)) != 1)
        {
            throw new DMLNoRecordEffectedException();
        }
        return result;
    }


    @Override
    public List<SysLoginLogBean> getList(SysLoginLogBean smSystemLoginLog)
    {
        return mapper.getList(smSystemLoginLog);
    }


    @Override
    public SysLoginLogBean getSingleById(Integer arg0)
    {
        return mapper.getSingleById(arg0);
    }


    @Override
    public int getCountOfPage(SysLoginLogBean smSystemLoginLog)
    {
        return mapper.getCountOfPage(smSystemLoginLog);
    }


    @Override
    public List<SysLoginLogBean> getListOfPage(SysLoginLogBean smSystemLoginLog)
    {
        return mapper.getListOfPage(smSystemLoginLog);
    }


	@Override
    public int getCount(SysLoginLogBean smSystemLoginLog)
    {
        return mapper.getCount(smSystemLoginLog);
    }


    @Override
    public void save(SysLoginLogBean smSystemLoginLog, BaseCommonParameterBean commonParam)
            throws DMLNoRecordEffectedException
    {
        if(smSystemLoginLog.getRowId() == null)
        {
            insert(smSystemLoginLog, commonParam);
        }
        else
        {
            updateBySelective(smSystemLoginLog, commonParam);
        }
    }


    @Override
    public SysLoginLogBean getSingle(SysLoginLogBean sysLoginLogBean)
    {
        return mapper.getSingle(sysLoginLogBean);
    }
}
